<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>注册统计</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">

    <link rel="stylesheet" type="text/css" th:href="@{/js/layui/css/layui.css}" media="all">
    <link rel="stylesheet" type="text/css" th:href="@{/css/cba/style.css/}" media="all">
    <link rel="stylesheet" type="text/css" th:href="@{/css/cba/my.css/}" media="all">
</head>
<body class="childrenBody">
    <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
        <ul class="layui-tab-title">
            <li class="layui-this">注册统计</li>
            <!--<li>登录统计</li>-->
        </ul>
        <div class="layui-tab-content">
            <!--注册统计页面-->
            <div class="layui-tab-item layui-show">
                <span style="float: right;font-size: 16px;color: #FF8C5A;">今日注册人数：<a style="font-weight: bold;font-size: 20px;color: red;" id="register">0</a></span>
                <div class="my-btn-box layui-form">
                    <span class="fr">
                        <div class="layui-input-inline">
                            <input type="text" autocomplete="off" id="recommendCodeId" name="recommendCode" placeholder="邀请码" class="layui-input height33">
                        </div>
                        <div class="layui-input-inline">
                          <input type="text" name="createTime" autocomplete="off" class="layui-input" id="createTimeId"  placeholder="开始时间">
                        </div>
                         <div class="layui-inline">
                            <button class="layui-btn layui-btn" id="search"><i class="layui-icon">&#xe615;</i>搜索</button>
                          </div>
                    </span>
                </div>
                <!-- 表格 -->
                <div id="dateTable" lay-filter="dateTable"></div>
                <div class="height50"></div>
            </div>
            <!--登录统计页面-->
            <div class="layui-tab-item">

            </div>
        </div>
    </div>
<script th:src="@{/js/fyn/my.js}"></script>
<script th:src="@{/js/layui/layui.js}"></script>
<script th:src="@{/js/cba/login-timeout.js}"></script>
<script type="text/javascript" th:inline="javascript">
    layui.use(['table', 'form', "layer",'laydate' , 'element'], function () {
        var form = layui.form
            , table = layui.table
            , layer = layui.layer
            , element = layui.element
            , laydate = layui.laydate
            , $ = layui.jquery;


        //审核时间
        var createTime = laydate.render({
            elem: '#createTimeId',
            type: 'date',
            format: 'yyyy-MM-dd',
            trigger:'click',
            value: getRecentDay(0),
            done: function(value, date){
            }
        });

        function getRecentDay(day){
            var today = new Date();
            var target_milliseconds = today.getTime() + 1000 * 60 * 60 * 24 * day;
            today.setTime(target_milliseconds);
            var tYear = today.getFullYear();
            var tMonth = today.getMonth();
            tMonth = doHandleMonth(tMonth + 1);
            var tDate = today.getDate();
            tDate = doHandleMonth(tDate);
            return tYear+"-"+tMonth+"-"+tDate;
        }
        function doHandleMonth(month) {
            var m = month;
            if (month.toString().length == 1) {
                m = "0" + month;
            }
            return m;
        }
        //加载列表
        var tableIns = table.render({
            elem: '#dateTable'                  //指定原始表格元素选择器（推荐id选择器）
            // , height: "full"    //容器高度
            // , skin: 'line'
            , even: 'true'
            , cols: [[                  //标题栏
                {field: 'id', title: 'ID', width: '20%', sort: true, align: 'center'}
                ,{field: 'nick', title: '昵称', width: '20%', align: 'center'}
                , {
                    field: 'mobile', title: '手机号', width: '20%', align: 'center', templet: function (d) {
                        return d.mobile == null ? '' : d.mobile;
                    }
                }
                , {field: 'recommendCode', title: '上级邀请码', width: '20%', align: 'center'}
                , {
                    field: 'ctime',
                    align: 'center',
                    title: '创建时间',
                    sort: true,
                    width: "20%",
                    templet: function (d) {
                        return new Date(d.ctime).Format("yyyy-MM-dd hh:mm:ss");
                    }
                }
                // , {title: '操作', align: 'center', width: "12%", toolbar: '#barOption'} //这里的toolbar值是模板元素的选择器
            ]]
            , id: 'dateTable'
            , url: [[${basePath}]] + '/member/regAndLogStatistic/registerList'
            , method: 'get'
            , page: true
            , limits: [10, 30, 60, 90, 150, 300]
            , toolbar: '#topOperate'
            , limit: 10 //默认采用0
            , loading: true
            // , where: getJson()
            , done: function (res, curr, count) {
                var count = count;
                $("#register").html(count);
                //如果是异步请求数据方式，res即为你接口返回的信息。
                //如果是直接赋值的方式，res即为：{data: [], count: 99} data为当前页数据、count为数据总长度
                $("td[data-field='content']").each(function () {
                    $(this).find(".layui-table-cell").removeClass('layui-table-cell');
                });

                // 查看登录IP
                $(".loginIP").on("click", function () {
                    var ss = $(this).next().css("display");
                    console.log(ss)
                    if (ss == "none") {
                        $(this).next().css("display", "");
                        $(this).text("隐藏最近登录IP");
                    } else {
                        $(this).next().css("display", "none");
                        $(this).text("显示最近登录IP");
                    }
                })


            }
        });


        $("#search").click(function () {
            tableIns.reload({
                where: {
                    recommendCode: $("#recommendCodeId").val(),
                    createTime: $("#createTimeId").val()
                },
                page: {
                    curr: 1
                }
            });
        })

        function getJson() {
            return {
                where: {
                    recommendCode: $("#recommendCodeId").val(),
                    createTime: $("#createTimeId").val()
                }
            };
        }
    });
</script>
</body>
</html>